/**
 * 
 */
package sailing.excel;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;

/**
 * @author kevin
 * 
 */
public abstract class Translator<T> {

	public abstract void fromRow(T t, Row row) throws TranslationException;

	public abstract void toRow(T t, Row row) throws TranslationException;

	public abstract boolean wouldParse(int rowNum);

	protected Object getCellValue(Cell cell) {
		switch (cell.getCellType()) {
		case Cell.CELL_TYPE_NUMERIC:
			return cell.getNumericCellValue();
		case Cell.CELL_TYPE_STRING:
			return cell.getStringCellValue();
		case Cell.CELL_TYPE_FORMULA:
			return "FormulaCell";
		case Cell.CELL_TYPE_BLANK:
			return "";
		case Cell.CELL_TYPE_BOOLEAN:
			return cell.getBooleanCellValue();
		case Cell.CELL_TYPE_ERROR:
			return String.valueOf(cell.getErrorCellValue());
			
		}
		return null;
	}

}
